#!/bin/bash

#set -o pipefail
set -o errexit

export LC_ALL=C

BASE_DATE=$1
AN_DIR=$2

MY_GENE_ID=$(cat $AN_DIR/gene.txt | head -n1 | cut -f1)
KEGG_GENE_ID=$(join -t$'\t' <(echo $MY_GENE_ID) ~/data/5_pathways/$BASE_DATE/gene_kegg_map.txt | cut -f2)
NCBI_GENE_ID=$(join -t$'\t' <(echo $KEGG_GENE_ID) ~/data/7_aux/kegg/$BASE_DATE/kegg2ncbi.txt | cut -f2)

if [ "x$KEGG_GENE_ID" == "x" ] ; then
    exit 0
fi

echo '###########################################'
echo -e "# KeggID: "$KEGG_GENE_ID"; GeneID: "$NCBI_GENE_ID

zcat $AN_DIR/e_5/results_gene_ontology.txt.gz \
    | head -n 5 \
    | 9_annotation_analysis/create_annotation_list.py ~/data/7_aux/gene_ontology/$BASE_DATE/go_names.txt

echo 

